// 云函数入口文件
const cloud = require('wx-server-sdk')

// cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
cloud.init({ env: 'radar-server-cloud-3d2qcee2c1b04' })

// 云函数入口函数
exports.main = async (event, context) => {
  let { mobile, device, desc } = event

  try {
    const result = await cloud.openapi.cloudbase.sendSms({
      "env": 'radar-server-cloud-3d2qcee2c1b04',
      "content": device + ', ' + desc,
      "phoneNumberList": [
        "+86" + mobile
      ],
      // "sms_type": 'Notification',
      // "template_id": '923584',
      // "template_param_list": [device, desc, '1']
    })
    return result
  } catch (err) {
    return err
  }
}